package com.ssm.lzh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.lzh.serachId.SerachId;
import com.ssm.lzh.service.ExerciseService;
import com.ssm.mapper.ExerciseMapper;
import com.ssm.pojo.exercise;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ExerciseServiceImpl implements ExerciseService {


    @Resource
    private ExerciseMapper exerciseMapper;

    @Resource
    private SerachId serachId;

    @Override
    public PageInfo<exercise> queryAllExercise(Page<exercise> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());

        return new PageInfo<exercise>(this.exerciseMapper.queryAllExercise(page.getSearchObj()));
    }

    @Override
    public int addExercise(exercise exercise) {
        String yd = serachId.ccid("YD");
        exercise.setExerciseid(yd);
        return this.exerciseMapper.addExercise(exercise);
    }

    @Override
    public int updateExercise(exercise exercise) {
       return this.exerciseMapper.updateExercise(exercise);
    }

    @Override
    public int deleteExercise(String id) {
        return this.exerciseMapper.deleteExercise(id);
    }
}
